package com.peanut.mvc.interseptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @className: com.peanut.mvc.congif-> TestInterceptor
 * @description: 拦截器
 * @author: chenhs
 * @createDate: 2021-09-19 16:07
 * @version: 1.0
 */
public class TestInterceptor  implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//请求处理前
        System.out.println("---------------------------------------preHandle");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//请求处理后
        System.out.println("---------------------------------------postHandle");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//返回数据前
        System.out.println("---------------------------------------afterCompletion");
    }
}
